<!-- Gets embedded anywhere we need to list comments on a top-level commentable. We need the local variable "commentable" here. -->
<div id="feedback" role="complementary">
	
  <h3 class="landmark">Actions</h3>
	<ul class="navigation" role="navigation">
    <% if @work || @admin_post %>
        <li><%= link_to '&#8593; '.html_safe + h(ts('Top')), :anchor => "main" %></li>
    <% end %>
    <% if @work && @previous_chapter %>
        <li><%= link_to '&#8592'.html_safe + h(ts('Previous Chapter')), [@work, @previous_chapter] %></li>
    <% end %>
    <% if @work && @next_chapter %>
        <li><%= link_to h(ts('Next Chapter')) + ' &#8594;'.html_safe, [@work, @next_chapter] %></li>
    <% end %>
    <% if @admin_post %>
        <li><%= link_to h(ts('Back to AO3 News Index')), admin_posts_path %></li>
    <% end %>
    <% if commentable.class.name == 'Work' || commentable.class.name == 'Chapter' %>
      <li>
        <% @kudo = Kudo.new %>
        <%= form_for @kudo do |kudo_form| %>
          <%= kudo_form.hidden_field :commentable_id, :value => commentable.id %>
          <%= kudo_form.hidden_field :commentable_type, :value => commentable.class.name %>
          <%= kudo_form.submit ts("Leave Kudos ♥") %>
        <% end %>
      </li>
    <% end %>
    <% if @work && is_author_of?(@work) %>
        <li id="add_collection_link"><%= collection_link(@work) %></li>
    <% end %>
    <% if logged_in? && @work %>
        <li id="add_bookmark_link"><%= bookmark_link(commentable) %></li>
    <% end %>
    <% if commentable.count_visible_comments > 0 && !commentable.is_a?(Tag) %>
        <li id="show_comments_link"><%= show_hide_comments_link(commentable) %></li>
    <% end %>
  </ul>

  <!-- if we have javascript, here is where the collection window will pop up -->
  <div id="dynamic-collection_item" class="wrapper" style="display:none;"></div>
  <!-- if we have javascript, here is where the bookmark window will pop up -->
  <div style="position:relative;"><div id="dynamic-bookmark" class="wrapper" style="display:none;"></div></div>

  <h3 class="landmark"><a name="comments">Comments</a></h3>

  <%= flash_div :comment_error, :comment_notice %>

  <% if commentable.respond_to?(:kudos) %>
    <%= render "kudos/kudos", :kudos => commentable.kudos.with_pseud.order("created_at DESC"), :guest_kudos_count => commentable.kudos.by_guest.count %>
  <% end %>

  <div id="add_comment_placeholder">
    <div id="add_comment">
      <%= render :partial => 'comments/comment_form', :locals => {:comment => Comment.new, :commentable => commentable, :button_name => ts('Add Comment')}%> 		
    </div>
  </div>

  <!-- If we have javascript, here is where the comments will be spiffily inserted -->
  <!-- If not, and show_comments is true, here is where the comments will be rendered -->
  <% if params[:show_comments] || params[:tag_id] %>
		<div id="comments_placeholder">
      <%= render :partial => 'comments/comment_thread', 
                 :locals => { :depth => 0, :comments => commentable.comments } %>
      </ol><!-- need to tack this on to close thread -->
    </div>
  <% else %>
    <div id="comments_placeholder" style="display: none;"></div>
  <% end %>

</div>
<!-- END comments -->
